﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApp5
{
    class 迭代器
    {
        public 迭代器()
        {
            Family family = new Family();
            foreach(string str in family)
            {
                Console.WriteLine(str);
            }
        }
    }
    class Family : System.Collections.IEnumerable
    {
        string[] MyFamily = { "你", "我", "他" };
        public IEnumerator GetEnumerator()
        {
            //throw new NotImplementedException();
            for (int i = 0; i < MyFamily.Length; i++)
            {
                yield return MyFamily[i];
            }
        }
    }
}
